home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.basic;
-
- import java.awt.Rectangle;
- import java.awt.event.FocusEvent;
- import java.awt.event.FocusListener;
- import java.awt.event.InputEvent;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseMotionListener;
- import java.io.Serializable;
-
- class BasicListUI$InputListener extends MouseAdapter implements MouseMotionListener, FocusListener, Serializable {
- // $FF: synthetic field
- BasicListUI this$0;
-
- public void mousePressed(MouseEvent e) {
- int row = this.this$0.convertYToRow(e.getY());
- if (row != -1) {
- this.this$0.list.setValueIsAdjusting(true);
- int anchorIndex = this.this$0.list.getAnchorSelectionIndex();
- if (((InputEvent)e).isControlDown()) {
- if (this.this$0.list.isSelectedIndex(row)) {
- this.this$0.list.removeSelectionInterval(row, row);
- } else {
- this.this$0.list.addSelectionInterval(row, row);
- }
- } else if (((InputEvent)e).isShiftDown() && anchorIndex != -1) {
- this.this$0.list.setSelectionInterval(anchorIndex, row);
- } else {
- this.this$0.list.setSelectionInterval(row, row);
- }
- }
-
- if (!this.this$0.hasFocus) {
- this.this$0.list.requestFocus();
- }
-
- }
-
- public void mouseDragged(MouseEvent e) {
- if (!((InputEvent)e).isShiftDown() && !((InputEvent)e).isControlDown()) {
- int row = this.this$0.convertYToRow(e.getY());
- if (row != -1) {
- Rectangle cellBounds = this.this$0.getCellBounds(this.this$0.list, row, row);
- if (cellBounds != null) {
- this.this$0.list.scrollRectToVisible(cellBounds);
- this.this$0.list.setSelectionInterval(row, row);
- }
- }
-
- }
- }
-
- public void mouseMoved(MouseEvent e) {
- }
-
- public void mouseReleased(MouseEvent e) {
- if (!((InputEvent)e).isShiftDown() && !((InputEvent)e).isControlDown()) {
- int row = this.this$0.convertYToRow(e.getY());
- if (row != -1) {
- this.this$0.list.setSelectionInterval(row, row);
- }
-
- this.this$0.list.setValueIsAdjusting(false);
- }
- }
-
- protected void repaintCellFocus() {
- int leadIndex = this.this$0.list.getLeadSelectionIndex();
- if (leadIndex != -1) {
- Rectangle r = this.this$0.getCellBounds(this.this$0.list, leadIndex, leadIndex);
- if (r != null) {
- this.this$0.list.repaint(r.x, r.y, r.width, r.height);
- }
- }
-
- }
-
- public void focusGained(FocusEvent e) {
- this.this$0.hasFocus = true;
- this.repaintCellFocus();
- }
-
- public void focusLost(FocusEvent e) {
- this.this$0.hasFocus = false;
- this.repaintCellFocus();
- }
-
- // $FF: synthetic method
- BasicListUI$InputListener(BasicListUI this$0) {
- this.this$0 = this$0;
- }
- }
-